<?php
	global $dept_id;
	$q  = new DBQuery;
	$q->addTable('contacts', 'con');
	$q->addQuery('contact_id');
	$q->addQuery('CONCAT(con.contact_first_name, " ", con.contact_last_name) AS contact_name');
	$q->addQuery('contact_email, contact_phone');
	$q->addWhere('contact_department='.$dept_id);
	$q->addWhere('(contact_owner = '.$AppUI->user_id.' or contact_private = 0)');
	$q->addOrder('contact_first_name');
	$contacts = $q->loadHashList('contact_id');
	$total = count($contacts);
?>
<table border="0" cellpadding="2" cellspacing="0" width="100%" class="infopanel">
<tr>
<td class="status">Total:</td>
<td width="100%"><?=$total?> <?=$total > 1 ? 'members' : 'member'?></td>
</tr>
</table>
<table border="0" cellpadding="2" cellspacing="0" width="100%" class="list">
<tr><th><?=$AppUI->_('Name')?></th><th><?=$AppUI->_('Email')?></th><th><?=$AppUI->_('Telephone')?></th></tr>
<?php
	if (!$total)
		showEmptyRow(3, 'padding');
	else
	foreach($contacts as $id => $data){
?>
	<tr class="second">
		<td><?=$data['contact_name']?></td>
		<td>
			<img src="images/mail.gif" border="0">&nbsp;
			<a href="mailto:<?=$data['contact_email']?>"><?=$data['contact_name'].' &lt;'.$data['contact_email'].'&gt;'?></a></td>
		<td><?=$data['contact_phone']?></td>
	</tr>
<?
	}
?>
</table>
